
var Name_bak;
var Id_bak;

function setClass(){
	
	var phoneId_bak = parent.Id_bak;
	var phoneId =parent.document.getElementById(phoneId_bak);
	
	var MyArray = document.getElementsByName("Num");
	var IdArray = phoneId.value.split(",");
	for(j=0;j<MyArray.length;j++){
		for(i=0;i<=IdArray.length;i++){
			if(MyArray[j].id==IdArray[i]){
				MyArray[j].className = 'labon';
				break;
				}
			else{
				MyArray[j].className = 'labout';
				}
			}
	}
}

function selectAll(name,id){
	var phoneName_bak = parent.Name_bak;
	var phoneId_bak = parent.Id_bak;
	var phoneName =parent.document.getElementById(phoneName_bak);
	var phoneId =parent.document.getElementById(phoneId_bak);
	
	var MyArray = document.getElementsByName("Num");
	var NameArray = phoneName.value.split(","); 
	var IdArray = phoneId.value.split(","); 
	var NameObj = name.split(",");
	var IdObj = id.split(",");
	var m ="";
	var n ="";
	
	for(j=0;j<IdObj.length;j++){
	
		for(i=0;i<=IdArray.length;i++){
			if(IdObj[j]==IdArray[i]){
			
			//先把重复的查出来，全删了，得到一个新的不包含此部门的数组，然后再把传进来的参数加到这个数组里面
				NameArray.splice(i,1);
				IdArray.splice(i,1);
				m = NameArray.join(',');
				n = IdArray.join(',');
				}
			if(j>0){
				var obj = j-1;
					MyArray[obj].className = 'labon';
				}
			}
		}
		
		if(n==""){
			phoneName.value = m + name;
			phoneId.value = n + id;
		}
		else{
			phoneName.value = m+","+name;
			phoneId.value = n+","+id;
		}
	}

function deletAll(name,id){
	var phoneName_bak = parent.Name_bak;
	var phoneId_bak = parent.Id_bak;
	var phoneName =parent.document.getElementById(phoneName_bak);
	var phoneId =parent.document.getElementById(phoneId_bak);
	
	var MyArray = document.getElementsByName("Num");
	var NameArray = phoneName.value.split(","); 
	var IdArray = phoneId.value.split(","); 
	var NameObj = name.split(",");
	var IdObj = id.split(",");
	var m ="";
	var n ="";
	for(j=0;j<IdObj.length;j++){
		for(i=0;i<=IdArray.length;i++){
			if(IdObj[j]==IdArray[i]){
				NameArray.splice(i,1);
				IdArray.splice(i,1);
				m = NameArray.join(',');
				n = IdArray.join(',');
				}
			}
		if(j>0){
			var obj = j-1;
				MyArray[obj].className = 'labout';
			}
		}
		phoneName.value = m+",";
		phoneId.value = n+",";
		if(n==""){
		phoneName.value = m;
		phoneId.value = n;
		}
	}


function addContent(name,id,obj){
	var phoneName_bak = parent.Name_bak;
	var phoneId_bak = parent.Id_bak;
	var phoneName =parent.document.getElementById(phoneName_bak);
	var phoneId =parent.document.getElementById(phoneId_bak);
	var NameArray = phoneName.value.split(","); 
	var IdArray = phoneId.value.split(","); 
	var oldcon = IdArray;
	var bakName = "";
	var bakId = "";
	for(i=0;i<oldcon.length;i++){
		if(oldcon[i]==id){
			NameArray.splice(i,1);
			IdArray.splice(i,1);
			var m = NameArray.join(',');
			var n = IdArray.join(',');
			phoneName.value = m;
			phoneId.value = n;
			bakName ="";
			bakId ="";
			obj.className = 'labout'
			break;
			}
		else {
			bakName = name+",";
			bakId = id+",";
			obj.className = 'labon'
		}
		}
	phoneName.value += bakName;
	phoneId.value += bakId;
}

var list_bak;
function opreatPhoneList(obj){
	var flcount = 0;
	var fl = document.getElementsByTagName('div');
	for(i=0;i<fl.length;i++){
		if(fl[i].className == 'phoneClu'){flcount++;}
		}
	if(!list_bak){
		list_bak = document.getElementById("list_1");
		}
	list_bak.style.display = 'none';
	var list = document.getElementById(obj);
	list_bak = list;
	list_bak.style.display = 'block';
	//alert(flcount);
	list_bak.style.height = 250 - flcount*23 +"px";
	}

function clearPhone(name,id){
	document.getElementById(name).value = '';
	document.getElementById(id).value = '';
	}
	
	
function checkPhone(name,id){
	Name_bak = name;
	Id_bak = id;
	var bodyh = document.body.clientHeight;
	var bodyw = document.body.clientWidth;
	var conh = document.body.scrollHeight;
	var phoneMain = document.getElementById("phoneMain");
	phoneMain.innerHTML = "<iframe style='width:100%; height:100%;' frameborder='0' scrolling='no' src='phoneText_0.html' id='childHtml' name='childHtml'></iframe>"
	
	var float_bg = document.getElementById("float_bg");
	var float_zz = document.getElementById("float_zz");
	var phoneDiv = document.getElementById("phoneDiv");
	
	float_bg.style.display = "block";
	float_zz.style.display = "block";
	phoneDiv.style.display = "block";
	
	float_bg.style.height = conh;
	float_zz.style.height = conh;
	
	var float_nrw = phoneDiv.offsetWidth;
	var float_nrh = phoneDiv.offsetHeight;
	phoneDiv.style.left = (bodyw-float_nrw)/2;
	phoneDiv.style.top = (bodyh-float_nrh)/2 + document.body.scrollTop;
	return;
	}
	
function closePhone(){
	var float_bg = document.getElementById("float_bg");
	var float_zz = document.getElementById("float_zz");
	var phoneDiv = document.getElementById("phoneDiv");
	
	float_bg.style.display = "none";
	float_zz.style.display = "none";
	phoneDiv.style.display = "none";
	}